<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<title>我的订单</title>

    <style type="text/css">
	.trheader
	{ 
	 border-top-style:outset;
	 border-top-color:#CCCCCC;
	 border-left-style:outset;
	 border-left-color:#CCCCCC;
	 border-right-style:outset;
	 border-right-color:#CCCCCC;
	 }
	.tritem
	{
	border-left-style:outset;
	border-right-style:outset;
	border-left-color:#CCCCCC;
	border-right-color:#CCCCCC;
	}
	.trfoot
	{
	 border-bottom-style:outset;
	 border-bottom-color:#CCCCCC;
	 border-left-style:outset;
	 border-left-color:#CCCCCC;
	 border-right-style:outset;
	 border-right-color:#CCCCCC;
	}
	</style>
    <!-- Bootstrap -->
    <link href="<%=request.getContextPath() %>/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="<%=request.getContextPath() %>/static/css/bootstrap-theme.min.css" rel="stylesheet">
    <link href="<%=request.getContextPath() %>/static/css/jumbotron.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="<%=request.getContextPath() %>/static/js/html5shiv.min.js"></script>
      <script src="<%=request.getContextPath() %>/static/js/respond.min.js"></script>
    <![endif]-->
    
    <script type="text/javascript">
    function postData(action, data) {
    	document.getElementById("inputAction").value = action;
    	document.getElementById("inputData").value = data;
    	document.getElementById("formPostData").submit();
    }
    </script>
</head>

<body>

  <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="<%=request.getContextPath()%>/">本草纲目网</a>
        </div>
        
        <c:if test="${user eq null }">
        <div id="navbar" class="navbar-collapse collapse">
          <form class="navbar-form navbar-right" method="post" action="<%=request.getContextPath()%>/Account/Login">
            <input type="hidden" name="action" value="login" />
            <div class="form-group">
              <input type="text" placeholder="账户" name="username" class="form-control">
            </div>
            <div class="form-group">
              <input type="password" placeholder="密码" name="password" class="form-control">
            </div>
            <button type="submit" class="btn btn-success">立即登陆</button>
            <a class="btn btn-info" href="<%=request.getContextPath() %>/Account/Register">马上注册</a>
          </form>
        </div><!--/.navbar-collapse -->
		</c:if>
		<c:if test="${user ne null }">
		<div id="navbar" class="navbar-collapse collapse">
		  <ul class="nav navbar-nav navbar-right">
		    <li><a>欢迎您，<b>${fn:escapeXml(user.realName) }</b>！</a></li>
		    <li><a href="<%=request.getContextPath() %>/Order/ShowMyOrders">我的订单</a></li>
		    <li><a href="<%=request.getContextPath() %>/Cart/ShowMyCart">我的购物车</a></li>
		    <li><a href="<%=request.getContextPath() %>/Account/Logout">注销</a></li>
		  </ul>
  		</div>
		</c:if>

      </div>
    </nav>


    <!-- Main jumbotron for a primary marketing message or call to action -->
    <!-- <div class="jumbotron">-->
      <div class="container">
        <h1 style="font-family:华文行楷;" >我的订单</h1>
       
       <br/><br/>   
       <div class="row">
<div class="col-lg-2">
</div>

<div class="col-lg-9"> 

<form method="post" id="formPostData">
  <input type="hidden" id="inputAction" name="action" value="" />
  <input type="hidden" id="inputData" name="data" value="" />
</form>

<table class="table">
  <!-- On rows -->
<tr class="active trheader">
  <td class="info">商品名</td>
  <td class="info">数量</td>
  <td class="info">单价</td>
  <td class="info">总价</td>
  <td class="info">状态</td>
  <td class="info">详情</td>
</tr>   

<c:forEach var="order" items="${page.records}">

 <tr class="trheader">
      <td colspan="6">
         <!-- <input type="checkbox"/> -->
         <label>订单号：${order.orderInfo.id } </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <label>总金额：${fn:escapeXml(order.orderInfo.transactionPrice) }元</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <label>创建时间：${fn:escapeXml(order.orderInfo.formattedCreatedDateTime) }</label>
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <label><a onclick="if (confirm('您确认要删除这个订单吗？')) postData('deleteOrder', ${order.orderInfo.id });return false;" href="#"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
          <span class="glyphicon-class"></span></a>
          </label>
      </td>
</tr>

<c:set var="i" value="0" />
<c:forEach var="gooditem" items="${order.goods}">
  <c:set var="i" value="${i+1 }" />

<tr class="tritem">
      <td ><a href="<%=request.getContextPath()%>/GoodItem/ShowGoodItem?id=${gooditem.goodItem.id }">${fn:escapeXml(gooditem.goodItem.name) }</a></td>
      <td >${fn:escapeXml(gooditem.quantity) }</td>
      <td >${fn:escapeXml(gooditem.transactionPrice) }元</td>
      <td >${fn:escapeXml(gooditem.totalPrice) }元</td>
      <c:if test="${i eq 1 }">
        <td rowspan="${order.goodCount }" style="vertical-align:middle">${fn:escapeXml(order.orderInfo.state.friendlyName) }</td>
        <td rowspan="${order.goodCount }" style="vertical-align:middle"><a href="ShowOrderDetail?id=${order.orderInfo.id }">查看详情</a></td>
      </c:if>
</tr>
 </c:forEach>
<tr class="trfoot">
    <td colspan="6"></td>
</tr>
 
</c:forEach>

</table>
<!-- 
<div class="row">
    <div class="col-lg-6" style="text-align:left">
         <input type="checkbox"/>全选
    </div>
    <div class="col-lg-3" style="text-align:right">
    总金额:<label id="totalvalue" style="color:red; font-size:x-large; font-family:"楷体"">${order.orderInfo.transactionPrice }  元</label>
    </div>
    <div class="col-lg-3" style="text-align:right">
    </div>
</div>
-->

<div class="row" style="text-align:center;">
      <nav> 
          <ul class="pagination">
          <c:choose>
		    <c:when test = "${page.hasPrevious}">
		    <li><a href="?curPage=1&pageSize=${page.pageSize}"><span aria-hidden="true">&laquo;</span></a></li>
            <li><a href="?curPage=${page.prePage}&pageSize=${page.pageSize}"><span aria-hidden="true">&lt;</span></a></li>
		    </c:when>
		    <c:otherwise>
		    <li class="disabled"><a href="#" onclick="return false;"><span aria-hidden="true">&laquo;</span></a></li>
		    </c:otherwise>
		    </c:choose>
		     
		    <c:if test="${page.currentPage-3 gt 0}">
            <li><a href = "?curPage=${page.currentPage-3}&pageSize=${page.pageSize}">${page.currentPage-3}</a></li>
            </c:if>
            <c:if test="${page.currentPage-2 gt 0}">
            <li><a href = "?curPage=${page.currentPage-2}&pageSize=${page.pageSize}">${page.currentPage-2}</a></li>
            </c:if>
            <c:if test="${page.currentPage-1 gt 0}">
            <li><a href = "?curPage=${page.currentPage-1}&pageSize=${page.pageSize}">${page.currentPage-1}</a></li>
            </c:if>
            <li class="active"><a href="#">${page.currentPage}</a></li>
             
             <c:if test="${page.maxPage - page.currentPage -0 gt 0}">
            <li><a href = "?curPage=${page.currentPage+1}&pageSize=${page.pageSize}">${page.currentPage+1}</a></li>
            </c:if>
            <c:if test="${page.maxPage - page.currentPage -1 gt 0}">
            <li><a href = "?curPage=${page.currentPage+2}&pageSize=${page.pageSize}">${page.currentPage+2}</a></li>
            </c:if>
            <c:if test="${page.maxPage - page.currentPage -2 gt 0}">
            <li><a href = "?curPage=${page.currentPage+3}&pageSize=${page.pageSize}">${page.currentPage+3}</a></li>
            </c:if>

            <c:choose>
		    <c:when test = "${page.hasNext}">
            <li><a href="?curPage=${page.nextPage}&pageSize=${page.pageSize}"><span aria-hidden="true">&gt;</span></a></li>
            <li><a href="?curPage=${page.maxPage}&pageSize=${page.pageSize}"><span aria-hidden="true"> &raquo; </span></a></li>
		    </c:when>
		    <c:otherwise>
		    <li class="disabled"><a href="#" onclick="return false;"><span aria-hidden="true">&raquo;</span></a></li>
		    </c:otherwise>
		    </c:choose>    
         </ul>
      </nav>
      </div>
      
      </div>
      </div>
      <footer style="padding-top:19px;color:#777;border-top:1px solid #e5e5e5">
        <p>&copy; 2016 中国药科大学理学院信息管理与信息系统13480班第3组</p>
      </footer>
      
  </div>
<!-- </div> -->

<script src="<%=request.getContextPath() %>/static/js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="<%=request.getContextPath() %>/static/js/bootstrap.min.js"></script>
</body>
</html>
